import React, { useState, useEffect } from 'react';
import { NavBar } from 'react-vant'
import axios from 'axios'
const Index = () => {
  const [swiperList, setSwiperList] = useState([]);
  const [menuList, setMenuList] = useState([]);
  const [list, setList] = useState([]);


  const getSwiperList = async () => {
    // 获取轮播图列表
    const resp = await axios.get('/api/swiper');
    // 设置轮播图列表
    setSwiperList(resp.data.data)
    // 打印响应数据
    console.log(resp.data)
  }
  const getMenuList = async () => {
    // 获取菜单列表
    const resp = await axios.get('/api/menu');
    // 设置菜单列表
    setMenuList(resp.data.data)
    // 打印响应数据
    console.log(resp.data)
  }
  const getList = async () => {
    // 获取列表
    const resp = await axios.get('/api/list');
    // 设置列表
    setList(resp.data.data)
    // 打印响应数据
    console.log(resp.data)
  }

  useEffect(() => {
    getSwiperList()
    getMenuList()
    getList()
  }, [])

  return (
    <div>
      {/* 头部 */}
      <NavBar title="首页" leftArrow={false}></NavBar>
      {/* 轮播 */}
      
      {/* 菜单 */}

      {/* 列表 */}
    </div>
  )
}

export default Index